package com.tanglongan.designPattern.dp20_strategy.demo00.worse;

public class WorseCouponDiscountService {

    /**
     * 根据类型计算费用
     *
     * @param type        优惠方式类型
     * @param typeContent 优惠券金额/折扣率
     * @param skuPrice    商品价格
     * @param typeExt     扩展参数
     */
    public double discount(int type, double typeContent, double skuPrice, double typeExt) {
        //直减券
        if (1 == type) {
            return skuPrice - typeContent;
        }
        //满减券
        if (2 == type) {
            if (skuPrice < typeExt) return skuPrice;
            return skuPrice - typeContent;
        }
        //折扣券
        if (3 == type) {
            return skuPrice * typeContent;
        }
        //N元购
        if (4 == type) {
            return typeContent;
        }

        return 0.0;
    }


}
